import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:free_music_player/models/song_model.dart';
import 'package:free_music_player/providers/music_provider.dart';
import 'package:free_music_player/widgets/search_screen.dart';
import 'package:free_music_player/widgets/history_screen.dart';
import 'package:free_music_player/widgets/playing_screen.dart';

class HomeScreen extends StatefulWidget {
  const HomeScreen({super.key});

  @override
  State<HomeScreen> createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
  int _currentIndex = 0;
  final List<Widget> _screens = [
    const SearchScreen(),
    const HistoryScreen(),
    const PlayingScreen(),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Free Music Player'),
        centerTitle: true,
      ),
      body: _screens[_currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: _currentIndex,
        onTap: (index) {
          setState(() {
            _currentIndex = index;
          });
        },
        items: const [
          BottomNavigationBarItem(
            icon: Icon(Icons.search),
            label: '搜索',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.history),
            label: '历史',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.music_note),
            label: '播放',
          ),
        ],
      ),
    );
  }
}